﻿package com.findMoneyGame.pages.home {
	
	import flash.display.MovieClip;
	import flash.events.Event;
	
	import com.findMoneyGame.Engine;
	import com.findMoneyGame.models.User;
	import com.findMoneyGame.models.Model;
	import com.findMoneyGame.pages.home.Note;
	
	public class NotePath extends MovieClip {
		
		
		public function NotePath() {
			super();
			User.getInst().addEventListener(Model.UPDATE, userUpdate);
			refresh();
		}

		private function userUpdate (e : Event) { refresh(); }

		private function refresh () {
			var levelsPassed = User.getInst().level % Engine.LEVELS_PER_SEASON;
			for (var i = 1; i < (Engine.LEVELS_PER_SEASON + 1); i++) {
				var noteName = 'note' + i.toString();
				(getChildByName(noteName) as Note).passed = i <= levelsPassed;
			}
		}
	}
	
}
